#ifndef UNIQUE_NAME_H
#define UNIQUE_NAME_H

#include <string>

class NameSpace;

class UniqueName
{
public:

    UniqueName();
    UniqueName(const std::string &name);

    virtual ~UniqueName();

    virtual inline NameSpace *nameSpace() const;

    virtual void setNameSpace(NameSpace *nameSpace);

    virtual const std::string name() const;
    virtual const char *c_str() const;

    // Sets the name and registrates it in the given NameSpace
    virtual const std::string setName(const std::string &name);
    virtual const std::string setName(
        const std::string& name
    ,   const bool &ignoreSameName);

    virtual bool operator<(const UniqueName &rhs) const;

    virtual bool operator==(const UniqueName &rhs) const;
    virtual bool operator!=(const UniqueName &rhs) const;

    // Warning: ignores the namespace! Use only if the namespace is the same
    virtual bool operator==(const std::string &rhs) const;
    virtual bool operator!=(const std::string &rhs) const;

    // Warning: ignores the namespace! Use only if the namespace is the same
    virtual bool operator==(const char *rhs) const;
    virtual bool operator!=(const char *rhs) const;

    virtual UniqueName& operator=(const UniqueName &rhs);
    virtual UniqueName& operator=(const std::string &rhs);
    virtual UniqueName& operator=(const char *rhs);

protected:
    std::string m_name;

    NameSpace*  m_nameSpace;
    bool        m_registered;

protected:

    // Tries to create a valid name syntax - leaves the name unchanged on fai
    virtual const bool makeValid(
        std::string &newName
    ,   const std::string &oldName
    ,   const bool &ignoreSameName);
};


#endif // UNIQUE_NAME_H
